home *** CD-ROM | disk | FTP | other *** search
/ EuroCD 3 / EuroCD 3.iso / Programming / Amos / AMOSList-0497 / AMOSLIST / text0138.txt < prev    next >
Encoding:
Text File  |  1998-06-24  |  1.3 KB  |  37 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6. Reply to Mush...
  7.  
  8. I think I know what you are trying to do in your box-line thing so I will
  9. try and explain two methods I know...
  10. To get the Y position of the slope as you go from one point to another can
  11. be solved by using either a linedraw routine or calculating the difference
  12. of Y position on the slope and adding it (negative gradients as well) to
  13. the current Y position...
  14.  
  15. The first method can be done by using a Bresnham (i think thats how you
  16. spell it ;-) line draw, this basically is a line draw routine that uses
  17. only integer numbers... you give the line routine the start and end (the
  18. top and bottom of you box) and for every increment in the x position, you
  19. will be able to get the y position, and becoz the box can probably be
  20. reflected horizontally you can just use -ypos+screenheight to get the
  21. bottom of the box Y co-ord.
  22.  
  23. The second method means getting the gradient of the slope and doing a loop
  24. from the start X to the end X of the box and for every point inbetween,
  25. increment the y position by the difference in heght between each pixel,
  26. this does mean using floating point numbers thought so it`s VERY slow, but
  27. then again, so was the first method(slow I mean...) but at least they work
  28. :-)
  29.  
  30. I will try and post the bresenham linedraw routine... I use it for
  31. raycasting at the moment(that will soon change though)
  32.  
  33. Lee Howarth
  34.  
  35.  
  36.  
  37.